package com.example.picassostudy;

import android.content.Context;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.util.Log;
import android.widget.ImageView;

import com.squareup.picasso.Callback;
import com.squareup.picasso.Picasso;
import com.squareup.picasso.RequestCreator;

public class MainActivity extends AppCompatActivity {
    private ImageView mImgPicasso;
    private Context mContext;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        mContext =MainActivity.this;
        findView();

    }

    private void findView() {
        mImgPicasso = (ImageView) findViewById(R.id.img_picasso);
        final String url = "http://upload.ugc.yanxiu.com/old/thumbnail_12073924_100x100.jpg";
        Picasso.with(mContext).load(url).resize(50, 50).centerCrop().placeholder(R.mipmap.ic_launcher).into(mImgPicasso, new Callback() {
            @Override
            public void onSuccess() {
                Log.e("frc", "onSuccess");
            }

            @Override
            public void onError() {
                Log.e("frc", "onError::::" + url);

            }
        });
        RequestCreator requestCreator =Picasso.with(MainActivity.this).load(url);

    }
}
